package com.damai.error;

import java.io.PrintWriter;

import com.citywithincity.utils.JsonUtil;

public class ApiError extends RuntimeException {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 5022554278909348952L;
	public static final String IO_ERROR = "网络错误，请稍后重试";
	
	public ApiError(String error){
		super(error);
	}
	
	
	private String reason;
	/**
	 * 
	 * @param error		错误信息
	 * @param code    	状态码
	 */
	public ApiError(String error,String reason){
		super(error);
		this.setReason(reason);
	}
	
	public ApiError(String error,Exception e){
		super(error,e);
	}
	
	
	
	public ApiError(){
		
	}
	

	public void render(PrintWriter writer) {
		writer.print(JsonUtil.alert(getMessage()));
	}

	public String getReason() {
		return reason;
	}

	public void setReason(String reason) {
		this.reason = reason;
	}

	
}
